package com.example.myapplication.fragment;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;

import com.example.myapplication.R;

/**
 * A simple {@link Fragment} subclass.
 */
public class f4third extends Fragment {

    private TextView shui;
    private Button button;
    private TextView shui2;
    View view;
    Context context;
    private ImageView touxiang;
    caa3 caa3;

    public f4third() {
        // Required empty public constructor
    }

    public static f4third getInstance(String game3) {
        f4third f4third = new f4third();
        Bundle bundle = new Bundle();
        bundle.putString("game", game3);
        f4third.setArguments(bundle);
        return f4third;
    }

    String game1;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        view = inflater.inflate(R.layout.fragment_f4third, container, false);
        context = getContext();
        initView();
        Bundle bundle = getArguments();
        game1 = bundle.getString("game");
        if (game1.equals("路飞赢了")) {
        touxiang.setImageResource(R.drawable.lufei);
        }
        if (game1.equals("女帝赢了")) {
            touxiang.setImageResource(R.drawable.nudi);
        }
        if (game1.equals("平局")) {
            touxiang.setImageResource(R.drawable.hhh);
        }
        shui.setText(game1);
        shui2.setText(game1);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                caa3.change3();
            }
        });
        return view;
    }

    private void initView() {
        shui = (TextView) view.findViewById(R.id.shui);
        button = (Button) view.findViewById(R.id.button);
        shui2 = (TextView) view.findViewById(R.id.shui2);
        touxiang = (ImageView) view.findViewById(R.id.touxiang);
    }
    @Override
    public void onAttach(@NonNull Context context) {
        super.onAttach(context);
        caa3 = (caa3) context;
    }
    public interface caa3 {
        public void change3();
    }
}
